package resource

import (
	"awesomeTask/application/variable"
	"awesomeTask/commom/MessageHelper"
	"awesomeTask/config"
	"awesomeTask/system/helper"
	"net"
)

type Manager interface {
	//资源分发 源代码
	DistributeSource(conn net.Conn, content string, path string)
	//接受处理收到的资源
	AcceptSource(content string, path string)
}

type ManagerObj struct {
}

/**
进行资源分发
*/
func (obj ManagerObj) DistributeSource(conn net.Conn, content string, path string) {
	info := map[string]interface{}{
		"content": content,
		"path":    path,
	}
	MessageHelper.SendEvent(variable.ON_DISTRIBUTE_SOURCE, info, conn)
}
func (obj ManagerObj) AcceptSource(content string, path string) {
	absPath := config.GetConfigByKey("projectPath").(string) + "/" + path
	helper.WriteFile(absPath, content, 0777)
}
